import React, { Component } from 'react'
import { connect } from 'dva';
import FormList from '../components/FormItem';
import { KEYS_EDIT } from '../enum';
import { UmiComponentProps, BaseComponentProps } from '@/common/type';

interface P {
  data?: {
    id?: string;
    valueRuleList: Array<any>;
    tMax?: number; tMin?: number;
    lMax?: number; lMin?: number;
    floorPlanX: string; floorPlanY: string;
    brandId?: string; productId?: string;
    brandName?: string; productName?: string;
    buildId?: string; floorId?: string; areaId?: string;
    buildName?: string; floorName?: string; areaName?: string;
  };
  match: any;
  details: object;
}

type Props = P & UmiComponentProps & BaseComponentProps;

@connect(({ device_gas }) => ({
  data: device_gas.editDetails
}))
class Update extends Component<Props> {

  componentDidMount() {
    const { dispatch, match } = this.props;
    const { params } = match;

    dispatch({
      type: 'device_gas/queryEditInfoById',
      payload: {
        id: params.id,
        keys: KEYS_EDIT
      }
    })
  }

  render() {
    return (
      <section className="edit">
        <FormList data={this.props.data} key={Date.now()}/>
      </section>
    );
  }
}

export default Update;
